﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


public partial class News_Newsdetail : System.Web.UI.Page
{
    PM.PMSys.news thenews = new PM.PMSys.news();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["id"] == null)
            {
                Server.Transfer("NewsList.aspx");
            }
            else
            {
                databind(int.Parse(Request.QueryString["id"]));
            }
        }
    }
     protected void databind(int newsid)
    {
        SqlDataReader reader = thenews.GetDetail(newsid);
        reader.Read();
         if (reader.HasRows)
         {
            lblType.Text = reader[1].ToString()+"类";
            lblTitle.Text = reader[2].ToString();
            lblContent.Text = reader[3].ToString();
            lblTime.Text = "发布时间:"+(DateTime.Parse(reader[4].ToString())).ToShortDateString();
         }
         else
         { 
             lblTitle.Text = "没有找到相应的新闻或公告";
             lblContent.Text = "请返回新闻列表页";
         }
        reader.Close();
    }
}
